#ifndef _RLE_H_
#define _RLE_H_

#include <vector>
#include <limits>

class RLEncoder
{
public:
	
	class Exception {};
	void reset();
	void charge(const void *data, size_t length);
	
	template <class T>
	void charge(const T &data) {return charge(&data, sizeof(data));}
	
	void commitEncode();
	void commitDecode();
	size_t getLength() const;
	const void *getBuffer() const;
	
private:
	typedef unsigned char Type;
	static const Type TYPE_MAX = static_cast<Type>(1 << (std::numeric_limits<Type>::digits - 1));
	// is it platform-dependent?
	std::vector<Type> buffer_;
	std::vector<Type> output_;
	bool isEncoding;
};

#endif
